home *** CD-ROM | disk | FTP | other *** search
- Path: news.panther.net!nemesis!hammy!not-for-mail
- From: gordon@sneaky.lerctr.org (Gordon Burditt)
- Newsgroups: comp.lang.c
- Subject: Re: beginner needs help about langtons's ant
- Date: 20 Apr 1996 22:54:51 -0500
- Organization: What organization?
- Message-ID: <4lcbib$1em@hammy.lonestar.org>
- References: <4lbrsi$4o@usc.edu>
- NNTP-Posting-Host: news.hammy.lonestar.org
-
- > char a[100][100];
- ...
- >int i,j;
- >for(i=0;i<=100;i++);
- >for(j=0;j<=100;j++);
- >a[i][j]=e;}
- ***ERROR*** subscript out of range. You probably don't want those
- semicolons on the for loops. As-is, this code is equivalent to:
-
- int i,j;
- i = 100;
- j = 100;
- a[100][100] = e;
-
- and since a is dimensioned 100 by 100, the highest legal subscripts
- are a[99][99].
-
- > void regular(int i, int j)
- > {
- > char a[100][100], b;
- >
- > if (a[i][j] == NULL)
-
- You haven't initialized this array, which is NOT the same as the a
- declared earlier, so why are you testing values in it?
-
- Gordon L. Burditt
- sneaky.lerctr.org!gordon
-